﻿/***************
 * Copyright 2009 (C) 
 * Timur Fanshteyn
 * Blog: http://blog.tfanshteyn.com
 * ************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tangosol.IO.Pof;

namespace Coherence.Contrib
{
    public class POFGenericSerializer : Tangosol.IO.Pof.IPofSerializer
    {
        IPofSerializer GenSerializer;
        public POFGenericSerializer(int typeId, Type type)
        {
            Type t = typeof(GenericSerializer<>).MakeGenericType(type);
            GenSerializer = (IPofSerializer)Activator.CreateInstance(t, new object[] { typeId });
        }
        #region IPofSerializer Members

        public object Deserialize(IPofReader reader)
        {
            return GenSerializer.Deserialize(reader);
        }

        public void Serialize(IPofWriter writer, object o)
        {
            GenSerializer.Serialize(writer, o);
        }

        #endregion
    }
}
